package com.ruoyi.web.controller.blogs;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.blogs.domain.BsCommentLikeRecord;
import com.ruoyi.blogs.service.IBsCommentLikeRecordService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 评论点赞点踩记录Controller
 * 
 * @author ruoyi
 * @date 2022-11-05
 */
@RestController
@RequestMapping("/blogs/commentLikeRecord")
public class BsCommentLikeRecordController extends BaseController
{
    @Autowired
    private IBsCommentLikeRecordService bsCommentLikeRecordService;

    /**
     * 查询评论点赞点踩记录列表
     */
    @PreAuthorize("@ss.hasPermi('blogs:commentLikeRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(BsCommentLikeRecord bsCommentLikeRecord)
    {
        startPage();
        List<BsCommentLikeRecord> list = bsCommentLikeRecordService.selectBsCommentLikeRecordList(bsCommentLikeRecord);
        return getDataTable(list);
    }

    /**
     * 导出评论点赞点踩记录列表
     */
    @PreAuthorize("@ss.hasPermi('blogs:commentLikeRecord:export')")
    @Log(title = "评论点赞点踩记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BsCommentLikeRecord bsCommentLikeRecord)
    {
        List<BsCommentLikeRecord> list = bsCommentLikeRecordService.selectBsCommentLikeRecordList(bsCommentLikeRecord);
        ExcelUtil<BsCommentLikeRecord> util = new ExcelUtil<BsCommentLikeRecord>(BsCommentLikeRecord.class);
        util.exportExcel(response, list, "评论点赞点踩记录数据");
    }

    /**
     * 获取评论点赞点踩记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('blogs:commentLikeRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(bsCommentLikeRecordService.selectBsCommentLikeRecordById(id));
    }

    /**
     * 新增评论点赞点踩记录
     */
    @PreAuthorize("@ss.hasPermi('blogs:commentLikeRecord:add')")
    @Log(title = "评论点赞点踩记录", businessType = BusinessType.INSERT)
    @Transactional
    @PostMapping
    public AjaxResult add(@RequestBody BsCommentLikeRecord bsCommentLikeRecord)
    {
        return toAjax(bsCommentLikeRecordService.insertBsCommentLikeRecord(bsCommentLikeRecord));
    }

    /**
     * 修改评论点赞点踩记录
     */
    @PreAuthorize("@ss.hasPermi('blogs:commentLikeRecord:edit')")
    @Log(title = "评论点赞点踩记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BsCommentLikeRecord bsCommentLikeRecord)
    {
        return toAjax(bsCommentLikeRecordService.updateBsCommentLikeRecord(bsCommentLikeRecord));
    }

    /**
     * 删除评论点赞点踩记录
     */
    @PreAuthorize("@ss.hasPermi('blogs:commentLikeRecord:remove')")
    @Log(title = "评论点赞点踩记录", businessType = BusinessType.DELETE)
    @Transactional
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(bsCommentLikeRecordService.deleteBsCommentLikeRecordByIds(ids));
    }
}
